unit dmda_MachineNo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dmModule, FR_DSet, FR_DBSet, DB, ADODB,fmda_MachineNoEdit;

type
  Tdtmda_MachineNo = class(TdtmModule)
    adsTree: TADODataSet;
    adsMasterRemark: TStringField;
    adsMasterHasStop: TBooleanField;
    adsMasterStoper: TStringField;
    adsMasterStopDate: TDateTimeField;
    adsMasterStopMemo: TStringField;
    adsMasterHasUse: TBooleanField;
    adsMasterHasSysdefine: TBooleanField;
    adsMasterHasCheck: TBooleanField;
    adsMasterHasDefault: TBooleanField;
    adsMasterChecker: TStringField;
    adsMasterCheckTime: TDateTimeField;
    adsMasterWriter: TStringField;
    adsMasterWriteTime: TDateTimeField;
    adsMasterModifier: TStringField;
    adsMasterModifyTime: TDateTimeField;
    adsMasterID: TStringField;
    adsMasterCode: TStringField;
    adsMasterName: TStringField;
    adsMasterInstallDate: TDateTimeField;
    adsDept: TADODataSet;
    adsMasterHelperCode: TStringField;
    adsMasterDeptID: TStringField;
    adsMasterCreateDate: TDateTimeField;
    adsMasterBuyDate: TDateTimeField;
    adsMasterMachineType: TStringField;
    adsMasterEditID: TStringField;
    adsMasterEditCode: TStringField;
    adsMasterEditName: TStringField;
    adsMasterEditHelperCode: TStringField;
    adsMasterEditDeptID: TStringField;
    adsMasterEditCreateDate: TDateTimeField;
    adsMasterEditBuyDate: TDateTimeField;
    adsMasterEditInstallDate: TDateTimeField;
    adsMasterEditMachineType: TStringField;
    adsMasterEditHasStop: TBooleanField;
    adsMasterEditStoper: TStringField;
    adsMasterEditStopDate: TDateTimeField;
    adsMasterEditStopMemo: TStringField;
    adsMasterEditHasUse: TBooleanField;
    adsMasterEditHasSysdefine: TBooleanField;
    adsMasterEditHasCheck: TBooleanField;
    adsMasterEditHasDefault: TBooleanField;
    adsMasterEditChecker: TStringField;
    adsMasterEditCheckTime: TDateTimeField;
    adsMasterEditWriter: TStringField;
    adsMasterEditWriteTime: TDateTimeField;
    adsMasterEditModifier: TStringField;
    adsMasterEditModifyTime: TDateTimeField;
    adsMasterEditRemark: TStringField;
    adsMasterMachineTypeName: TStringField;
    adsMasterRuleChildID: TStringField;
    adsMasterEditres_DeptName: TStringField;
    adsMasterEditres_MachineTypeName: TStringField;
    adsMasterDeptName: TStringField;
    adsMasterDeptFullName: TStringField;
    adsMasterEditMainDays: TIntegerField;
    adsMasterMainDays: TIntegerField;
    adsMasterEditSpecs: TStringField;
    adsMasterEditSNCode: TStringField;
    adsMasterEditStatus: TWordField;
    adsMasterSpecs: TStringField;
    adsMasterSNCode: TStringField;
    adsMasterStatus: TWordField;
    adsMasterStatusName: TStringField;
    adsMasterEditMchType: TStringField;
    adsMasterMchType: TStringField;
    adsMasterMchTypeName: TStringField;
    procedure adsMasterEditNameChange(Sender: TField);
    procedure adsMasterEditNewRecord(DataSet: TDataSet);
    procedure adsMasterEditCodeChange(Sender: TField);
  private

  protected
    procedure ModuleInit; override;
  public
    FDataType: string;
    procedure OpenEditDataSet;override;
  end;

var
  dtmda_MachineNo: Tdtmda_MachineNo;

implementation

uses uSQL;

{$R *.dfm}

{ Tdtmda_MachineNo }

procedure Tdtmda_MachineNo.ModuleInit;
begin
  FUniqueTable := 'da_MachineNo';
  inherited;
end;

procedure Tdtmda_MachineNo.OpenEditDataSet;
begin
  FMasterEditTable := 'da_MachineNo';
  FMasterKeyField := 'ID';
  inherited;

end;

procedure Tdtmda_MachineNo.adsMasterEditNameChange(Sender: TField);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) then
  begin
    adsMasterEdit.FieldByName('HelperCode').ReadOnly := False;
    adsMasterEdit.FieldByName('HelperCode').AsString := uSQL.GetHzPy(Sender.AsString);
  end;
end;

procedure Tdtmda_MachineNo.adsMasterEditNewRecord(DataSet: TDataSet);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) and (FDataType<>'') then
  begin
    adsMasterEdit.FieldByName('MachineType').ReadOnly := False;
    adsMasterEdit.FieldByName('MachineType').AsString := FDataType;
  end;
end;

procedure Tdtmda_MachineNo.adsMasterEditCodeChange(Sender: TField);
begin
  inherited;
  {if (adsMasterEdit.State in [dsInsert, dsEdit]) then
  begin
    adsMasterEdit.FieldByName('Name').ReadOnly := False;
    adsMasterEdit.FieldByName('Name').AsString := Sender.AsString;
  end;
  }
end;

end.
